package com.example.eventdistribution;

import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private MyViewGroup mContainer;
    private static final String TAG = "MainActivity";
    private MyViewGroup myViewGroup;

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        return super.dispatchTouchEvent(ev);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();

        View view = new View(this);
        ViewGroup.LayoutParams params=new ViewGroup.LayoutParams(300,300);
        view.setBackgroundColor(getResources().getColor(R.color.colorAccent));
        view.setLayoutParams(params);
        myViewGroup.addView(view);
        myViewGroup.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                Log.d(TAG, "onTouch: ");
                return false;
            }
        });
        view.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                Log.d(TAG, "onTouch: ");
                return false;
            }
        });
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.d(TAG, "onClick: ");
            }
        });
    }

    private void initView() {
        myViewGroup = (MyViewGroup) findViewById(R.id.myViewGroup);
    }
}